package tuijianhaoyou;

import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;


public class T {
    public static class HaoYouReduce extends Reducer<Text,Text,Text,Text> {
        @Override
        protected void reduce(Text friend, Iterable<Text> users, Context context) throws IOException, InterruptedException {
            ArrayList<String> Userlist = new ArrayList<String>();
            for (Text User:users){
                Userlist.add(User.toString());
            }
            Collections.sort(Userlist);
            for (int i = 0; i <Userlist.size()-1 ; i++) {
                for (int j = 0; j <Userlist.size() ; j++) {
                    context.write(new Text(Userlist.get(i)+"-"+Userlist.get(j)),friend);
                }
            }
        }
    }

}
